# Josephe 问题

m = input().split(' ')
n, k = int(m[0]), int(m[1])

list = list(range(1, n + 1))

num = 0 # 计数器

while len(list) > 1:
    if num == k - 1:
        print(list[0], end = ' ')
        del list[0]
        num = 0
    else:
        list.append(list[0])
        del list[0]
        num += 1